<template>
	<view class="after_sale_data" v-if="showView">
		<view class="sale_step">
			<view class="before" :class="[saleInfo.status > 0?'active':'']" :style="{width:beforePar.width + 'px' , left: beforePar.left + 'px'}"></view>
			<view class="after" :class="[saleInfo.status > 1?'active':'']" :style="{width:afterPar.width+'px',left:afterPar.left + 'px'}"></view>
			<view class="sale_step-item">
				<view class="top">
					<image src="https://master.jiaju01.com/web/shopImgs/sale_success.png"></image>
				</view>
				<view class="bot">提交成功</view>
			</view>
			<view class="sale_step-item" :class="[saleInfo.status > 0 ? 'active':'']">
				<view class="top"><text>2</text></view>
				<view class="bot">处理中</view>
			</view>
			<view class="sale_step-item" :class="[saleInfo.status > 1 ? 'active':'']">
				<view class="top"><text>3</text></view>
				<view class="bot">已处理</view>
			</view>
		</view>
		<view class="pro-info">
			<image :src="saleInfo.goods.image_middle"></image>
			<view class="pro-info-txt">
				<view class="pro-info-tit">{{saleInfo.goods.goods_name}}</view>
				<view class="pro-info-sn">款号：{{saleInfo.goods.goods_sn}}</view>
			</view>
		</view>
		<view class="after-info">
			<view class="after-info-tit">基本信息</view>
			<view class="after-info-cell">
				<text class="after-info-cell-left">订单商品编号</text>
				<text class="after-info-cell-right">{{saleInfo.order_sn}}</text>
			</view>
			<view class="after-info-cell">
				<text class="after-info-cell-left">售后类型</text>
				<text class="after-info-cell-right red" v-if="saleInfo.type==0">待处理</text>
				<text class="after-info-cell-right" v-if="saleInfo.type==1">驳回</text>
				<text class="after-info-cell-right" v-if="saleInfo.type==2">换货</text>
				<text class="after-info-cell-right" v-if="saleInfo.type==3">补件</text>
				<text class="after-info-cell-right" v-if="saleInfo.type==4">修理</text>
				<text class="after-info-cell-right" v-if="saleInfo.type==5">退货</text>
				<text class="after-info-cell-right" v-if="saleInfo.type==6">其他</text>
			</view>
			<view class="after-info-cell">
				<text class="after-info-cell-left">责任划分</text>
				<text class="after-info-cell-right red" v-if="saleInfo.type==0">待处理</text>
				<text class="after-info-cell-right" v-if="saleInfo.type==1">客户</text>
				<text class="after-info-cell-right" v-if="saleInfo.type==2">总部</text>
				<text class="after-info-cell-right" v-if="saleInfo.type==3">工厂</text>
				<text class="after-info-cell-right" v-if="saleInfo.type==4">物流</text>
				<text class="after-info-cell-right" v-if="saleInfo.type==5">仓库</text>
			</view>
			<view class="after-info-cell last">
				<text class="after-info-cell-left">售后描述</text>
				<text class="after-info-cell-right">{{saleInfo.content}}</text>
			</view>
			<view class="go-order-info" @click="goOrderInfo">查看订单 ></view>
		</view>
		<view class="img-item" v-for="(item,index) in saleItem" :key="index" v-if="item.imgList.length">
			<view class="img-item-tit">{{item.title}}</view>
			<view class="img-item-list">
				<image v-for="(imgItem,sindex) in item.imgList" :src="imgItem.image" @click="previewImg(sindex,imgItem.image)" :key="sindex"></image>
			</view>
		</view>
		<pt-loading></pt-loading>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				showView:false,
				saleInfo: '',
				order_after_id: '',
				beforePar: {
					width: 0,
					left: 0
				},
				afterPar: {
					width: 0,
					left: 0
				},
				saleItem: [{
					title: '上传整体图',
					imgList: []
				}, {
					title: '上传细节图',
					imgList: []
				}, {
					title: '上传包装图',
					imgList: []
				}]
			};
		},
		onLoad(options) {
			this.order_after_id = options.order_after_id
			this.init()
		},
		methods: {
			init() {
				let data = {
					order_after_id: this.order_after_id
				}
				this.$u.apiWei.saleList(data).then(res => {
					this.saleInfo = res.datas[0]
					if (this.saleInfo.image_list && this.saleInfo.image_list.length) {
						this.saleInfo.image_list.forEach(item => {
							if (item.type == 1) {
								this.saleItem[0].imgList.push(item)
							} else if (item.type == 2) {
								this.saleItem[1].imgList.push(item)
							} else {
								this.saleItem[2].imgList.push(item)
							}
						})
					}
					this.showView = true
				})
			},
			goOrderInfo() {
				uni.navigateTo({
					animationDuration: 500,
					url: '/my/my-order/order-details/order-details?id=' + this.saleInfo.order_id
				})
			},
			previewImg(index, url) {
				let arr = []
				this.saleItem[index].imgList.forEach(item => {
					arr.push(item.image)
				})
				uni.previewImage({
					current:url,
					urls: arr
				});
			}
		}
	}
</script>

<style lang="scss">
	.after_sale_data {

		.sale_step {
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin: 50rpx 70rpx;
			padding: 0 0 10rpx;
			position: relative;
		}

		.sale_step .before {
			position: absolute;
			top: 25rpx;
			height: 1px;
			border-bottom: dotted 2px #E6E6E6;
		}

		.sale_step .before.active {
			border-color: #EF8200;
		}

		.sale_step .after.active {
			border-color: #EF8200;
		}

		.sale_step .after {
			position: absolute;
			top: 25rpx;
			height: 1px;
			border-bottom: dotted 2px #E6E6E6;
		}

		.sale_step-item {
			text-align: center;
		}

		.sale_step-item.active text {
			background-color: #EF8200;
			color: #FFF;
		}

		.sale_step-item image {
			width: 52rpx;
			height: 52rpx;
			vertical-align: top;
			margin-bottom: 20rpx;
		}

		.sale_step-item text {
			display: inline-block;
			vertical-align: top;
			width: 52rpx;
			height: 52rpx;
			border-radius: 50%;
			background-color: #E6E6E6;
			font-size: 32rpx;
			color: #2E2E2E;
			margin-bottom: 20rpx;
			text-align: center;
			line-height: 52rpx;
		}

		.bot {
			font-size: 24rpx;
		}

		.pro-info {
			display: flex;
			background-color: #FFF;
			padding: 30rpx;
			margin: 20rpx;
			border-radius: 10rpx;
			align-items: center;
		}

		.pro-info image {
			width: 176rpx;
			height: 176rpx;
			background-color: #EEE;
			border-radius: 10rpx;
			margin-right: 20rpx;
		}

		.pro-info-txt {
			flex: 1;
			min-width: 0;
		}

		.pro-info-tit {
			font-size: 28rpx;
			white-space: nowrap;
			overflow: hidden;
			text-overflow: ellipsis;
			margin-bottom: 30rpx;
		}

		.pro-info-sn {
			color: #999;
			font-size: 24rpx;
		}

		.after-info {
			background-color: #FFF;
			margin: 20rpx;
			padding: 30rpx;
			border-radius: 10rpx;
		}

		.after-info-tit {
			font-size: 32rpx;
		}

		.after-info-cell {
			padding: 50rpx 0;
			border-bottom: solid 1px #F7F7F7;
			display: flex;
			justify-content: space-between;
		}

		.after-info-cell-left {
			font-size: 28rpx;
			color: #666;
			width: 7em;
		}

		.after-info-cell-right {
			font-size: 32rpx;
			color: #000;
			flex: 1;
			text-align: right;
		}

		.after-info-cell-right.red {
			color: red;
		}

		.last {
			border-bottom: none;
		}

		.last .after-info-cell-right {
			text-align: left;
		}

		.go-order-info {
			text-align: center;
			height: 88rpx;
			line-height: 88rpx;
			background: rgba(255, 255, 255, 1);
			border: 2rpx solid rgba(242, 242, 242, 1);
			border-radius: 10rpx;
			font-size: 28rpx;
			color: #EF8200;
		}

		.img-item {
			margin: 20rpx;
			padding: 30rpx;
			background-color: #FFF;
			border-radius: 10rpx;
		}

		.img-item-tit {
			color: #666;
			font-size: 32rpx;
			padding-bottom: 20rpx;
			border-bottom: solid 1px #F7F7F7;
		}

		.img-item-list {
			display: flex;
			flex-wrap: wrap;
		}

		.img-item-list image {
			width: 200rpx;
			height: 200rpx;
			margin: 20rpx 20rpx 0 0;
			background-color: #EEE;
		}

		.img-item-list image:nth-child(3n) {
			margin-right: 0;
		}
	}
</style>
